﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>密码键盘测试工具</title>
    <script type="text/javascript" src="../ocx/PinPad.js"></script>
</head>
<div>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="设置键盘类型"
           onclick="setPinpadTypeByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="打开设备"
           onclick="openDeviceByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="关闭设备"
           onclick="closeDeviceByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="初始化"
           onclick="initDeviceByPinPad()"/>
</div>
<div>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="下载原始密钥"
           onclick="loadAKeyByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="下载主密钥"
           onclick="loadMasterKeyByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="下载工作密钥"
           onclick="loadWorkKeyByPinPad()"/>
    <input type="button"
           style="color:white;
           width:100px;
           height:50px;
           background-color:#6495ed"
           value="数据运算"
           onclick="calDataByPinPad()"/>
</div>
<div>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="密码输入"
           onclick="getPinPressByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="计算密文"
           onclick="calPinBlockByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="计算Mac值"
           onclick="calMacByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="明文输入"
           onclick="getUserPressByPinPad()"/>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="终止输入"
           onclick="cancelPressByPinPad()"/>
</div>
<div>
    <input type="button"
           style="color:white;
       width:100px;
       height:50px;
       background-color:#6495ed"
           value="固件版本信息"
           onclick="getVersionByPinPad()"/>
</div>
<div>
    <input id="result"
           type="text"
           style="width:90%;height:50px;
           margin-top:30px;
           margin-right:50px"
           readonly="readonly"/>
</div>

<object
               id="PinpadId"
               classid="CLSID:CDCCA94F-6009-4252-A5A5-E8AC64395611"
               name="PinpadId">
     
</object>

<script>
    function setPinpadTypeByPinPad() {
        var ret = setPinpadType()
        document.getElementById("result").value = ret;
    }

    function openDeviceByPinPad() {
        var ret = openPinPadDevice()
        document.getElementById("result").value = ret;
    }

    function closeDeviceByPinPad() {
        closePinPadDevice()
    }

    function initDeviceByPinPad() {
        initPinPad()
    }

    function loadAKeyByPinPad() {
        var ret = loadAKey('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function loadMasterKeyByPinPad() {
        var ret = loadMasterKey('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function loadWorkKeyByPinPad() {
        var ret = loadWorkKey('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function calDataByPinPad() {
        var ret = calData('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function getPinPressByPinPad() {
        var ret = getPinPress()
        document.getElementById("result").value = ret;
    }

    function calPinBlockByPinPad() {
        var ret = calPinBlock('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function calMacByPinPad() {
        var ret = calMac('1234567890123456')
        document.getElementById("result").value = ret;
    }

    function getUserPressByPinPad() {
        var ret = getUserPress()
        document.getElementById("result").value = ret;
    }

    function cancelPressByPinPad() {
        var ret = cancelPress()
        document.getElementById("result").value = ret;
    }

    function getVersionByPinPad() {
        var ret = getVersion()
        document.getElementById("result").value = ret;
    }
</script>

<script for="PinpadId" EVENT='OnUserPress' language="JavaScript">
    document.getElementById("result").value = PinpadId.KeyValue;
</script>
<script for="PinpadId" EVENT='OnUserPressComplete' language="JavaScript">
    document.getElementById("result").value = '用户输入完成';
</script>
<script for="PinpadId" EVENT='OnUserCancel' language="JavaScript">
    document.getElementById("result").value = '用户取消输入';
</script>
<script for="PinpadId" EVENT='OnUserPressTimeOut' language="JavaScript">
    document.getElementById("result").value = '用户输入超时';
</script>
</html>